﻿<!DOCTYPE html>
<html lang="en">
<head th:replace="~{parts/head}">

<!-- page wrapper -->
<body>

    <div class="boxed_wrapper">

        <!-- preloader -->
        <div class="preloader"></div>
        <!-- preloader -->


        <!-- main header -->
        <header class="main-header style-three">

            <!-- header-lower -->
            <div class="header-lower">
                <div class="outer-box clearfix">
                    <div class="left-column">
                        <div class="logo-box">
                            <figure class="logo"><a href="/"><img src="../../images/logo-3.png" alt=""></a></figure>
                        </div>
                        <div th:replace="~{parts/menu-area}">
                    </div>
                    <div class="right-column pull-right">
                        <div th:replace="~{parts/author-box}">
                    </div>
                </div>
            </div>

            <!--sticky Header-->
            <div class="sticky-header">
                <div class="auto-container">
                    <div class="outer-box">
                        <div class="logo-box">
                            <figure class="logo"><a href="/"><img src="../../images/small-logo.png" alt=""></a></figure>
                        </div>
                        <div class="menu-area">
                            <nav class="main-menu clearfix">
                                <!--Keep This Empty / Menu will come through Javascript-->
                            </nav>
                        </div>
<!--                        <div class="btn-box"><a href="register-page.html" class="theme-btn-one"><i class="icon-image"></i>Join Now</a></div>-->
                    </div>
                </div>
            </div>
        </header>
        <!-- main-header end -->

        <!-- Mobile Menu  -->
        <div class="mobile-menu">
            <div class="menu-backdrop"></div>
            <div class="close-btn"><i class="fas fa-times"></i></div>
            
            <nav class="menu-box">
                <div class="nav-logo"><a href="/"><img src="../../images/logo-2.png" alt="" title=""></a></div>
                <div class="menu-outer"><!--Here Menu Will Come Automatically Via Javascript / Same Menu as in Header--></div>
                <div class="contact-info">
                    <h4>Contact Info</h4>
                    <ul>
                        <li>Chicago 12, Melborne City, USA</li>
                        <li><a href="">+88 01682648101</a></li>
                        <li><a href="mailto:info@example.com">info@example.com</a></li>
                    </ul>
                </div>
                <div class="social-links">
                    <ul class="clearfix">
                        <li><a href="/"><span class="fab fa-twitter"></span></a></li>
                        <li><a href="/"><span class="fab fa-facebook-square"></span></a></li>
                        <li><a href="/"><span class="fab fa-pinterest-p"></span></a></li>
                        <li><a href="/"><span class="fab fa-instagram"></span></a></li>
                        <li><a href="/"><span class="fab fa-youtube"></span></a></li>
                    </ul>
                </div>
            </nav>
        </div><!-- End Mobile Menu -->


        <!--page-title-two-->
        <section class="page-title-two">
            <div class="title-box centred bg-color-2">
                <div class="pattern-layer">
                    <div class="pattern-1" style="background-image: url(../../images/shape/shape-70.png);"></div>
                    <div class="pattern-2" style="background-image: url(../../images/shape/shape-71.png);"></div>
                </div>
                <div class="auto-container">
                    <div class="title">
                        <h1>出诊信息</h1>
                    </div>
                </div>
            </div>
            <div class="lower-content">
                <ul class="bread-crumb clearfix">
                    <li><a href="/">主页</a></li>
                    <li><a style="cursor: pointer" onclick="window.history.back(-1);">上一页</a></li>
                    <li>出诊信息</li>
                </ul>
            </div>
        </section>
        <!--page-title-two end-->


        <!-- doctors-dashboard -->
        <section class="doctors-dashboard bg-color-3">
            <div class="left-panel">
                <div class="profile-box patient-profile">
                    <div class="upper-box">
                        <figure class="profile-image"><img th:src="${user.icon}" alt=""></figure>
                        <div class="title-box centred">
                            <div class="inner">
                                <h3 th:text="${user.name}">Dr. Rex Allen</h3>
<!--                                <p><i class="fas fa-calendar-alt"></i>Oct 05, 2083,  38 Years</p>-->
                            </div>
                        </div>
                    </div>
                    <div class="profile-info">
                        <ul class="list clearfix">
                            <th:block th:replace="~{parts/doc-dash}"></th:block>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="right-panel">
                <div class="content-container">
                    <div class="outer-container">
                        <div class="add-listing my-profile">
                            <form id="info-form">
                            <div class="single-box">
                                <div class="title-box">
                                    <h3>出诊信息</h3>
                                </div>
                                <div class="inner-box">
                                    <input class="d-none" id="patId" name="id" type="text" th:value="${outcome ne null ? outcome.id : ''}">
                                    <input class="d-none" id="userId" name="id" type="text" th:value="${user.id}">
                                    <div class="row clearfix">
                                        <div class="col-lg-6 col-md-6 col-sm-12 form-group">
                                            <label><strong>科室</strong></label>
                                            <select class="wide" id="clinicId">
                                                <option data-display="选择科室">选择科室</option>
                                                <option th:each="item:${clinics}" th:text="${item.name}" th:value="${item.id}" th:selected="${outcome ne null and item.id eq outcome.clinicId}">Select Text 01</option>
                                            </select>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 form-group">
                                            <label><strong>医生</strong></label>
                                            <div class="row">
                                                <div class="custom-check-box col-lg-3 col-md-6 col-sm-12" th:if="${user.role eq '0'}" th:each="item:${doctors}">
                                                    <div class="custom-controls-stacked">
                                                        <label class="custom-control material-checkbox">
                                                            <input type="checkbox" class="material-control-input" name="docList" th:id="${'doc_checkbox_'+item.id}" th:value="${item.id}" th:checked="${#lists.contains(docIdList, item.id)}">
                                                            <span class="material-control-indicator"></span>
                                                            <span class="description" th:text="${item.name}"></span>
                                                        </label>
                                                    </div>
                                                </div>
                                                <div class="custom-check-box col-lg-3 col-md-6 col-sm-12" th:if="${user.role eq '1'}">
                                                    <div class="custom-controls-stacked">
                                                        <label class="custom-control material-checkbox">
                                                            <input type="checkbox" class="material-control-input" name="docList" th:value="${user.id}" checked>
                                                            <span class="material-control-indicator"></span>
                                                            <span class="description" th:text="${user.name}"></span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 form-group">
                                            <label><strong>日期</strong></label>
                                            <input type="text" id="date" name="date" placeholder="选择日期" required="" th:value="${outcome ne null ? outcome.date : ''}" readonly>
                                        </div>
                                        <div class="col-lg-6 col-md-6 col-sm-12 form-group">
                                            <label><strong>时间段</strong></label>
                                            <div class="row">
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 0}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_0" value="0" th:checked="${outcome ne null and outcome.period eq 0}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">8:00-9:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 1}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_1" value="1" th:checked="${outcome ne null and outcome.period eq 1}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">9:00-10:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 2}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_2" value="2" th:checked="${outcome ne null and outcome.period eq 2}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">10:00-11:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 3}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_3" value="3" th:checked="${outcome ne null and outcome.period eq 3}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">13:00-14:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 4}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_4" value="4" th:checked="${outcome ne null and outcome.period eq 4}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">14:00-15:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 5}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_5" value="5" th:checked="${outcome ne null and outcome.period eq 5}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">15:00-16:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="custom-check-box col-lg-6 col-md-6 col-sm-12" th:if="${outcome eq null or outcome.period eq 6}">
                                                <div class="custom-controls-stacked">
                                                    <label class="custom-control material-checkbox">
                                                        <input type="checkbox" class="material-control-input" name="period" id="period_6" value="6" th:checked="${outcome ne null and outcome.period eq 6}">
                                                        <span class="material-control-indicator"></span>
                                                        <span class="description">16:00-17:00</span>
                                                    </label>
                                                </div>
                                            </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                                <div class="btn-box">
                                    <a style="cursor:pointer;" class="theme-btn-one" onclick="save()">保存修改<i class="icon-Arrow-Right"></i></a>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- doctors-dashboard -->


        <!-- main-footer -->
        <div th:replace="~{parts/main-footer}"></div>
        <!-- main-footer end -->

        <div th:replace="~{parts/alert-modal}"></div>
        <!--Scroll to top-->
        <button class="scroll-top scroll-to-target" data-target="html" onclick='location.href=("/message?targetId=6")'>
            <img src="../../images/robot-2.png">
        </button>
    </div>

    <script th:replace="~{parts/js}"></script>
    <script>
        $('#doc_tab').addClass("current");
        $("#date").datetimepicker({
            format: 'yyyy/mm/dd',
            autoclose: true,
            language: 'zh-CN',
            minView: 2
        });
        function save() {
            var period_chk_value =[];
            $('input[name="period"]:checked').each(function(){
                period_chk_value.push($(this).val());
            });
            var docList_chk_value =[];
            $('input[name="docList"]:checked').each(function(){
                docList_chk_value.push($(this).val());
            });

            $.ajax({
                type: "post",
                url:"/outcome-details/save",
                cache: false,
                data: {
                    date: $('#date').val(),
                    periods: period_chk_value,
                    clinicId: $('#clinicId').val(),
                    docList: docList_chk_value
                },
                success: function (data) {
                    if (data.state === "success") {
                        $('#saveSuccessModal').modal('show');
                    }
                },
                error: function(res) {
                    $('#saveFailModal').modal('show');
                }
            });
        }
        function insertSuccess() {
            window.location.href='/outcome';
        }
    </script>
    <style>
        .nice-select {
            position: relative;
            display: block;
            width: 100%;
            height: 50px;
            border-radius: 10px;
            border: solid 1px #e8e8e8 !important;
            background: transparent;
            font-size: 16px;
            color: #848484;
            padding: 4px 24px;
        }
        .nice-select:after {
            top: 10px;
        }
    </style>
</body><!-- End of .page_wrapper -->
</html>
